<#import "html-macro.ftl" as h />
<#import "declaration-macro.ftl" as d/>
<#escape x as x?html>
<#--<form class="ui large goodsForm">-->
<div class="dashedbar text-blue"><span>商品信息</span></div>
    <#if !pdfMode??>
    <div class="ui grid goodsForm" id="commodities">
        <div class="row">
            <input type="hidden" id="id"/>
            <@h.label  width="2" value="商品序号" required=true />
            <@h.input width="3" id="index_num" readonly=true />
            <#if d.declarationType__>
                <@h.label width="2" value="手册备案序号" required=true/>
                <@h.input width="4" id="record_id" readonly=d.isGeneralTrade__/>
            <#else>
                <@h.label width="2" value="合同商品项目序号" required=true/>
                <@h.input width="4" id="contractNumber" readonly=d.isGeneralTrade__/>
            </#if>
            <@h.label width="2" value="商品编号"  required=true/>
            <@h.dropdown width="3" id="code_t" />
            <input type="hidden" id="code_s"/>
            <@h.label width="2" value="商品名称"  required=true />
            <@h.input width="3" id="name"/>
            <#if d.declarationType__>
                <@h.label width="2" value="规格型号"/>
                <@h.input width="4" id="key_elements"  />
            <#else>
                <@h.label width="2" value="规格型号"/>
            <#--<@h.input width="6" id="key_elements"  />-->
                <@h.input width="4" id="goods_mode"  />
            </#if>
            <#if d.declarationType__>
                <#if d.isGeneralTrade__>
                    <@h.label width="2" value="要素"  required=true/>
                    <@h.input width="3" id="goods_mode"  />
                <#else>
                    <@h.label width="2" value="要素"/>
                    <@h.input width="3" id="goods_mode" readonly=true />
                </#if>
            </#if>
            <#if !d.declarationType__>
                <@h.label  width="2" value="征免"  required=true />
                <@h.dropdown width="3" id="levyModeCode" showId="levymode"/>
            </#if>
            <@h.label width="2" value="计价数量"  required=true />
            <@h.input width="3" id="count" dataType="float" />
            <@h.label width="2" value="计价单位"  required=true />
            <@h.dropdown width="4" id="unitCode" showId="unit"  />
            <@h.label width="2" value="总价"  required=true />
            <@h.input width="3" id="total_price" dataType="float" />
            <@h.label  width="2" value="法定数量"  required=true />
            <@h.input width="3" id="legal_count" dataType="float" />
            <@h.label width="2" value="法定单位"  required=true />
            <#if d.declarationType__>
                <@h.dropdown width="4" id="legalUnitCode" showId="legal_unit" readonly=true/>
            <#else>
                <@h.dropdown width="4" id="legalUnitCode" showId="legal_unit"/>
            </#if>
            <@h.label width="2" value="单价"  required=true />
            <@h.input width="3" id="unit_price" dataType="float" readonly=true />
            <@h.label width="2" value="第二数量"  />
            <@h.input width="3" id="second_count" dataType="float" readonly=true/>
            <@h.label width="2" value="第二计量单位" />
        <#-- <#if d.declarationType__>-->
            <@h.dropdown width="4" id="secondUnitCode" showId="second_unit" readonly=true/>
        <#--<#else>
            <@h.dropdown width="4" id="secondUnitCode" showId="second_unit" readonly=true/>
        </#if>-->
            <@h.label  width="2" value="币制"  required=true />
            <@h.dropdown width="3" id="currencyCode" showId="currency" />

            <#if d.declarationType__>
                <@h.label width="2" value="目的国"  required=true />
                <@h.dropdown width="3" id="destination_code" showId="destination"/>
                <@h.label  width="2" value="原产国"  required=true />
                <@h.dropdown width="4" id="origin_country_code" showId="origin_country" />
            <#else>
                <@h.label width="2" value="原产国"  required=true />
                <@h.dropdown width="3" id="origin_country_code" showId="origin_country" />
                <@h.label width="2" value="目的国"  required=true />
                <@h.dropdown width="4" id="destination_code" showId="destination"/>
            </#if>
            <#if d.declarationType__>
                <@h.label  width="2" value="征免"  required=true />
                <@h.dropdown width="3" id="levyModeCode" showId="levymode"/>
            </#if>

            <#if d.declarationType__><#--出口-->
                <@h.label width="2" value="包装种类" required=true  />
                <@h.input width="3" id="package_type" />
                <@h.label width="2" value="包装件数"  required=true />
                <@h.input width="4" id="goods_number" dataType="float" />
                <@h.label width="2" value="毛重(KG)"  required=true />
                <@h.input width="3" id="goods_gross_weight" dataType="float" />
                <@h.label width="2" value="净重(KG)" required=true  />
                <@h.input width="3" id="goods_net_weight" dataType="float" />
                <@h.label width="2" value="版本号" />
                <@h.input width="4" id="version_no" readonly=d.isGeneralTrade__/>
                <#if d.isGeneralTrade__><#--一般贸易-->
                    <@h.label width="2" value="货号" />
                    <@h.input width="3" id="goods_no" readonly=true/>
                <#else>
                    <@h.label width="2" value="货号" />
                    <@h.input width="3" id="goods_no" />
                <#--<@h.label width="2" value="工缴费"  required=true />
                <@h.input width="3" id="processing_fee" dataType="float" />-->
                </#if>


                <@h.label width="2" value="工缴费"/>
                <@h.input width="3" id="processing_fee" name="processing_fee" dataType="long" />
                <@h.label width="2" value="装箱单备注内容" />
                <@h.input width=d.isGeneralTrade__?string("4","3") id="packinglist_remark" />



            <#--<#else>
                <#if !d.isGeneralTrade__>
                    <@h.label value="工缴费"  required=true />
                    <@h.input width="2" id="processing_fee" dataType="float" />
                </#if>-->
            </#if>
        </div>
    </div>
    </#if>
<#--<div class="errorMsgContainer">
    <div class="bg"></div>
    <div class="ui error message">
        <div class="modal-head">错误提示</div>
        <div class="modal-body"></div>
        <div class="modal-foot">
            <button class="ui blue button closeError tiny">确定</button>
        </div>
    </div>
</div>-->

<#--只读模式不显示-->
    <#if !h.readMode__>
    <div class="row ui grid button-line">
        <div class="sixteen wide column right floated">
            <button id="goodsAdd" class="mini ui labeled icon button blue right floated">
                <i class="plus icon"></i>
                添加
            </button>
            <button id="goodsSave"
                    class="mini ui labeled icon button  blue right floated saveGoodsSubmit">
                <i class="save icon"></i>
                保存商品
            </button>
            <button id="goodsCancle"
                    class="mini ui labeled icon button  blue right floated ">
                <i class="remove icon"></i>
                取消
            </button>
        </div>
    </div>
    </#if>
<#--</form>-->
<table id="goodsTable" class="ui celled table center aligned"
       style="font-size: 12px;">
    <thead>
    <th>序号</th>
        <#if d.isProcessTrade__>
            <#if !d.declarationType__>
            <th>合同商品项目序号</th>
            <#else>
            <th>手册备案序号</th>
            </#if>
        </#if>
    <th>商品编号</th>
    <th>商品名称</th>
    <th>计价数量</th>
    <th>计价单位</th>
        <#if !d.declarationType__>
        <th>总价/币制</th>
        <#else>
        <th>装箱单备注内容</th>
        </#if>
    <#--只读模式不显示-->
        <#if !h.readMode__>
        <th>操作</th>
        </#if>
    </thead>
    <tbody>
        <#list declaration.commodities as cmmo>
        <tr>
            <input name="commodities[${cmmo_index}].id" type="hidden"
                   value="${cmmo.id}">
            <input name="commodities[${cmmo_index}].index_num" type="hidden"
                   value="${cmmo.index_num}">
            <#if d.isProcessTrade__>
                <#if !d.declarationType__>
                    <input name="commodities[${cmmo_index}].contractNumber" type="hidden"
                           value="${cmmo.contractNumber}">
                <#else>
                    <input name="commodities[${cmmo_index}].record_id" type="hidden"
                           value="${cmmo.record_id}">
                </#if>
            </#if>
            <input name="commodities[${cmmo_index}].code_s" type="hidden"
                   value="${cmmo.code_s}">
            <input name="commodities[${cmmo_index}].code_t" type="hidden"
                   value="${cmmo.code_t}">
            <input name="commodities[${cmmo_index}].name" type="hidden"
                   value="${cmmo.name}">
            <input name="commodities[${cmmo_index}].key_elements" type="hidden"
                   value="${cmmo.key_elements}">
            <input name="commodities[${cmmo_index}].goods_mode" type="hidden"
                   value="${cmmo.goods_mode}">
            <input name="commodities[${cmmo_index}].count" type="hidden"
                   value="${cmmo.count}">
            <input name="commodities[${cmmo_index}].unitCode" type="hidden"
                   value="${cmmo.unitCode}">
            <input name="commodities[${cmmo_index}].unit" type="hidden"
                   value="${cmmo.unit}">
            <input name="commodities[${cmmo_index}].total_price" type="hidden"
                   value="${cmmo.total_price}">
            <input name="commodities[${cmmo_index}].unit_price" type="hidden"
                   value="${cmmo.unit_price}">
            <input name="commodities[${cmmo_index}].currencyCode" type="hidden"
                   value="${cmmo.currencyCode}">
            <input name="commodities[${cmmo_index}].currency" type="hidden"
                   value="${cmmo.currency}">
            <input name="commodities[${cmmo_index}].legal_count" type="hidden"
                   value="${cmmo.legal_count}">
            <input name="commodities[${cmmo_index}].legalUnitCode" type="hidden"
                   value="${cmmo.legalUnitCode}">
            <input name="commodities[${cmmo_index}].legal_unit" type="hidden"
                   value="${cmmo.legal_unit}">
            <input name="commodities[${cmmo_index}].destination" type="hidden"
                   value="${cmmo.destination}">
            <input name="commodities[${cmmo_index}].destination_code" type="hidden"
                   value="${cmmo.destination_code}">
            <input name="commodities[${cmmo_index}].origin_country" type="hidden"
                   value="${cmmo.origin_country}">
            <input name="commodities[${cmmo_index}].origin_country_code" type="hidden"
                   value="${cmmo.origin_country_code}">
            <input name="commodities[${cmmo_index}].levyModeCode" type="hidden"
                   value="${cmmo.levyModeCode}">
            <input name="commodities[${cmmo_index}].levymode" type="hidden"
                   value="${cmmo.levymode}">
            <input name="commodities[${cmmo_index}].second_count" type="hidden"
                   value="${cmmo.second_count}">
            <input name="commodities[${cmmo_index}].secondUnitCode" type="hidden"
                   value="${cmmo.secondUnitCode}">
            <input name="commodities[${cmmo_index}].second_unit" type="hidden"
                   value="${cmmo.second_unit}">
            <input name="commodities[${cmmo_index}].version_no" type="hidden"
                   value="${cmmo.version_no}">
            <input name="commodities[${cmmo_index}].goods_no" type="hidden"
                   value="${cmmo.goods_no}">
            <input name="commodities[${cmmo_index}].processing_fee" type="hidden"
                   value="${cmmo.processing_fee}">
            <input name="commodities[${cmmo_index}].package_type" type="hidden"
                   value="${cmmo.package_type}">
            <input name="commodities[${cmmo_index}].goods_gross_weight" type="hidden"
                   value="${cmmo.goods_gross_weight}">
            <input name="commodities[${cmmo_index}].goods_net_weight" type="hidden"
                   value="${cmmo.goods_net_weight}">
        <#--<input name="commodities[${cmmo_index}].boxMark" type="hidden"
               value="${cmmo.boxMark}">-->
            <input name="commodities[${cmmo_index}].goods_number" type="hidden"
                   value="${cmmo.goods_number}">
            <input name="commodities[${cmmo_index}].packinglist_remark" type="hidden"
                   value="${cmmo.packinglist_remark}">
            <td>${cmmo.index_num}</td>
            <#if d.isProcessTrade__>
                <td>
                    <#if !d.declarationType__>
                    ${cmmo.contractNumber}
                    <#else>
                    ${cmmo.record_id}
                    </#if>
                </td>
            </#if>
            <td>${cmmo.code_t}${cmmo.code_s}</td>
            <td>${cmmo.name}</td>
            <td>${cmmo.count}</td>
            <td>${cmmo.unit}</td>
            <#if !d.declarationType__>
                <td>${cmmo.total_price}${cmmo.currency}</td>
            <#else>
                <td>${cmmo.packinglist_remark}</td>
            </#if>
        <#--<td>${cmmo.packinglist_remark}</td>-->

        <#--只读模式不显示-->
            <#if !h.readMode__>
                <td>
                    <button class="ui mini primary basic button">修改</button>
                    <button class="ui mini negative basic button">删除</button>
                    <button class="ui mini purple basic button">复制</button>
                    <button class="ui mini black basic button"><i class="arrow up icon"></i>
                    </button>
                    <button class="ui mini brown basic button"><i class="arrow down icon"></i>
                    </button>
                </td>
            </#if>
        </tr>
        </#list>
    </tbody>
    <tfoot>
    <tr>
        <th colspan="8">
            <#if d.declarationType__>
                <div class="ui basic label">件数总汇:
                    <div class="detail total-goods-count">
                        件
                    </div>
                </div>
                <div class="ui basic label">毛重总汇:
                    <div class="detail total-gross-weight">
                        千克
                    </div>
                </div>
                <div class="ui basic label">净重总汇:
                    <div class="detail total-net-weight">
                        千克
                    </div>
                </div>
            </#if>
            <div class="ui basic label">总价总汇:
                <div class="detail">
                    币制
                </div>
            </div>
        </th>
    </tr>
    </tfoot>
</table>
    <#if pdfMode??>
        <#list declaration.commodities as sfd>
        <div class="ui grid goodsForm ">
            <div class="row">
                <input type="hidden" id="id"/>
                <@h.label  width="2" value="商品序号" required=true />
                <@h.input width="3" id="index_num" readonly=true value="${sfd.index_num}"/>
                <#if d.declarationType__>
                    <@h.label width="2" value="手册备案序号" required=true/>
                    <@h.input width="4" id="record_id" readonly=d.isGeneralTrade__ value="${sfd.record_id}"/>
                <#else>
                    <@h.label width="2" value="合同商品项目序号" required=true/>
                    <@h.input width="4" id="contractNumber" readonly=d.isGeneralTrade__ value="${sfd.contractNumber}"/>
                </#if>
                <@h.label width="2" value="商品编号"  required=true/>
                <@h.dropdown width="3" id="code_t"  value="${sfd.code_t}"/>
                <input type="hidden" id="code_s" value="${sfd.code_s}"/>
                <@h.label width="2" value="商品名称"  required=true />
                <@h.input width="3" id="name" value="${sfd.name}"/>
                <#if d.declarationType__>
                    <@h.label width="2" value="规格型号"/>
                    <@h.input width="4" id="key_elements"  value="${sfd.key_elements}"/>
                <#else>
                    <@h.label width="2" value="规格型号"/>
                    <@h.input width="4" id="goods_mode"  value="${sfd.goods_mode}"/>
                </#if>
                <#if d.declarationType__>
                    <#if d.isGeneralTrade__>
                        <@h.label width="2" value="要素"  required=true/>
                        <@h.input width="3" id="goods_mode"  value="${sfd.goods_mode}"/>
                    <#else>
                        <@h.label width="2" value="要素"/>
                        <@h.input width="3" id="goods_mode" readonly=true value="${sfd.goods_mode}"/>
                    </#if>
                </#if>
                <#if !d.declarationType__>
                    <@h.label  width="2" value="征免"  required=true />
                    <@h.dropdown width="3" id="levyModeCode" showId="levymode" value="${sfd.levyModeCode}" showValue="${sfd.levymode}"/>
                </#if>
                <@h.label width="2" value="计价数量"  required=true />
                <@h.input width="3" id="count" dataType="float" value="${sfd.count}"/>
                <@h.label width="2" value="计价单位"  required=true />
                <@h.dropdown width="4" id="unitCode" showId="unit"  value="${sfd.unitCode}" showValue="${sfd.unit}"/>
                <@h.label width="2" value="总价"  required=true />
                <@h.input width="3" id="total_price" dataType="float" value="${sfd.total_price}"/>
                <@h.label  width="2" value="法定数量"  required=true />
                <@h.input width="3" id="legal_count" dataType="float" value="${sfd.legal_count}"/>
                <@h.label width="2" value="法定单位"  required=true />
                <#if d.declarationType__>
                    <@h.dropdown width="4" id="legalUnitCode" showId="legal_unit" readonly=true value="${sfd.legalUnitCode}" showValue="${sfd.legal_unit}"/>
                <#else>
                    <@h.dropdown width="4" id="legalUnitCode" showId="legal_unit" value="${sfd.legalUnitCode}" showValue="${sfd.legal_unit}"/>
                </#if>
                <@h.label width="2" value="单价"  required=true />
                <@h.input width="3" id="unit_price" dataType="float" readonly=true value="${sfd.unit_price}"/>
                <@h.label width="2" value="第二数量"  />
                <@h.input width="3" id="second_count" dataType="float" readonly=true value="${sfd.second_count}"/>
                <@h.label width="2" value="第二计量单位" />
                <@h.dropdown width="4" id="secondUnitCode" showId="second_unit" readonly=true value="${sfd.secondUnitCode}" showValue="${sfd.second_unit}"/>
                <@h.label  width="2" value="币制"  required=true />
                <@h.dropdown width="3" id="currencyCode" showId="currency" value="${sfd.currencyCode}" value="${sfd.secondUnitCode}" showValue="${sfd.currency}"/>

                <#if d.declarationType__>
                    <@h.label width="2" value="目的国"  required=true />
                    <@h.dropdown width="3" id="destination_code" showId="destination" value="${sfd.destination_code}" showValue="${sfd.destination}"/>
                    <@h.label  width="2" value="原产国"  required=true />
                    <@h.dropdown width="4" id="origin_country_code" showId="origin_country" value="${sfd.origin_country_code}" showValue="${sfd.origin_country}"/>
                <#else>
                    <@h.label width="2" value="原产国"  required=true />
                    <@h.dropdown width="3" id="origin_country_code" showId="origin_country" value="${sfd.origin_country_code}" showValue="${sfd.origin_country}"/>
                    <@h.label width="2" value="目的国"  required=true />
                    <@h.dropdown width="4" id="destination_code" showId="destination" value="${sfd.destination_code}" showValue="${sfd.destination}"/>
                </#if>
                <#if d.declarationType__>
                    <@h.label  width="2" value="征免"  required=true />
                    <@h.dropdown width="3" id="levyModeCode" showId="levymode" value="${sfd.levyModeCode}" showValue="${sfd.levymode}"/>
                </#if>

                <#if d.declarationType__>
                    <@h.label width="2" value="包装种类" required=true  />
                    <@h.input width="3" id="package_type" value="${sfd.package_type}"/>
                    <@h.label width="2" value="包装件数"  required=true />
                    <@h.input width="4" id="goods_number" dataType="float" value="${sfd.goods_number}"/>
                    <@h.label width="2" value="毛重(KG)"  required=true />
                    <@h.input width="3" id="goods_gross_weight" dataType="float" value="${sfd.goods_gross_weight}"/>
                    <@h.label width="2" value="净重(KG)" required=true  />
                    <@h.input width="3" id="goods_net_weight" dataType="float" value="${sfd.goods_net_weight}"/>
                    <@h.label width="2" value="版本号" />
                    <@h.input width="4" id="version_no" readonly=d.isGeneralTrade__ value="${sfd.version_no}"/>
                    <#if d.isGeneralTrade__>
                        <@h.label width="2" value="货号" />
                        <@h.input width="3" id="goods_no" readonly=true value="${sfd.goods_no}"/>
                    <#else>
                        <@h.label width="2" value="货号" />
                        <@h.input width="3" id="goods_no" value="${sfd.goods_no}"/>
                    </#if>
                    <@h.label width="2" value="工缴费"/>
                    <@h.input width="3" id="processing_fee" name="processing_fee" dataType="long" value="${sfd.processing_fee}"/>
                    <@h.label width="2" value="装箱单备注内容" />
                    <@h.input width=d.isGeneralTrade__?string("4","3") id="packinglist_remark" value="${sfd.packinglist_remark}"/>
                </#if>
                <#if d.isGeneralTrade__>
                    <#if d.declarationType__>
                        <div class="five wide column"></div>
                        <@h.label width="2" value="备注要素"  required=true/>
                        <@h.input width="14" id="goods_mode"  value="${sfd.goods_mode}"/>
                    <#else>
                        <div class="five wide column"></div>
                        <@h.label width="2" value="备注规格型号"/>
                        <@h.input width="14" id="goods_mode"  value="${sfd.goods_mode}"/>
                    </#if>
                </#if>
            </div>
        </div>
        </#list>
    </#if>
</#escape>